#ifndef CAP_ADS1118_H
#define CAP_ADS1118_H

#include "zh_main.h"
#include "iMath.h"
#define CAPBUFSIZE 10
#define CAP_CALI_LEN 100/*校准点之间的距离(mm)*/

#define	CHIP_ADS1118 0
#define	CHIP_ADS7950 1
extern const char ADSCHIP_NAME[2][5];



typedef struct  CapADS_TypeDef
{
    uint16_t CapBuf[CAPBUFSIZE];    //电压原始值缓存(用于滤波)
    uint16_t Cap;           //当前电压原始值(滤波结果)
    uint16_t K;               //电压换算比例(量程为±4.096v，k=0.125mV)
    uint8_t Cnt;            //更新次数
	uint8_t ADSChip;
    uint16_t (*GetX)(void);
    uint16_t (*GetV)(void); 
}CapADS_t;

#define ADS_CS_L()  HAL_GPIO_WritePin(NSS_GPIO_Port,NSS_Pin,GPIO_PIN_RESET);
#define ADS_CS_H()  HAL_GPIO_WritePin(NSS_GPIO_Port,NSS_Pin,GPIO_PIN_SET);
extern Line_polyfit_t CAPpoly;
extern CapADS_t CA;
void ADS_Getdata (void);
uint16_t CapADS_GetX(void);
uint16_t CapADS_GetCapv(void);
void CapADS_Calibrate(void);
void CapADS_Scan(void); 

#endif



